package com.ysx.server.mapper;


import com.github.pagehelper.Page;
import com.ysx.server.pojo.dto.ReportDTO;
import com.ysx.server.pojo.dto.ReportPageQueryDTO;
import com.ysx.server.pojo.entity.Report;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author ysx
* @description 针对表【report(举报表)】的数据库操作Mapper
* @createDate 2024-02-15 15:56:34
* @Entity com/ysx/server/pojo.domain.Report
*/
@Mapper
public interface ReportMapper {
    /**
     * 分页查询
     * @param reportPageQueryDTO
     * @return
     */
    Page<Report> page(ReportPageQueryDTO reportPageQueryDTO);

    /**
     * 修改评论信息
     * @param report
     * @return
     */
    boolean update(Report report);

    /**
     * 通过id删除评论信息
     * @param id
     * @return
     */
    @Delete("delete from second_hand_trading.report where id=#{id}")
    boolean deleteById(Long id);

    /**
     * 通过用户id查找举报信息
     * @param userId
     * @return
     */
    @Select("select * from second_hand_trading.report where userId=#{userId}")
    List<Report> getByUserId(Long userId);

    /**
     * 通过商品id查询举报信息
     * @param goodsId
     * @return
     */
    @Select("select * from second_hand_trading.report where goodsId=#{goodsId}")
    List<Report> getByGoodsId(Long goodsId);

    @Insert("insert into second_hand_trading.report(goodsId, goodsName, userId, username, reportDescription) values(#{goodsId},#{goodsName},#{userId},#{username},#{reportDescription})")
    void saveReport(Report report);
}




